﻿using Db4objects.Db4o;

namespace DataAccess
{

    /// <summary>
    /// Deactivate action class.
    /// </summary>
    class DeactivateAction : IUpdateAction
    {

        /// <summary>
        /// The object to be deactivated.
        /// </summary>
        private object objectToDeactivate;

        /// <summary>
        /// The depth of the deactivation in the object graph.
        /// </summary>
        private int deactivateDepth;


        /// <summary>
        /// DeactivateAction constructor.
        /// </summary>
        /// <param name="objectToDeactivate">The object to be deactivated</param>
        /// <param name="deactivateDepth">The depth of the deactivation in the object graph</param>
        public DeactivateAction(object objectToDeactivate, int deactivateDepth)
        {
            this.objectToDeactivate = objectToDeactivate;
            this.deactivateDepth = deactivateDepth;
        }


        /// <summary>
        /// Performs the deactivation action against the database.
        /// </summary>
        /// <param name="db">The database handle</param>
        public void PerformUpdate(IObjectContainer db)
        {
            db.Deactivate(objectToDeactivate, deactivateDepth);
        }

    }

}